package com.cgsrp.cgsrp_user_province.controller;

import com.cgsrp.cgsrp_user_province.domain.UserAddress;
import com.cgsrp.cgsrp_user_province.service.UserAddressService;
import com.cgsrp.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("address")
public class AddressController {
    @Autowired
    private UserAddressService addressService;

    @GetMapping("list")
    public Result list(Integer userId){
        return addressService.list(userId);
    }

    @PostMapping("add")
    public Result add(UserAddress address){
        return addressService.insert(address)>0?Result.success("添加地址成功"):Result.failure("添加地址失败");
    }
}
